package com.bootdo.market.dao;

import org.apache.ibatis.annotations.Select;

import java.util.Map;

public interface DuplicateDao {

    @Select("\t\tselect `id`,`channelId`,`channelName`,`channelType`,`channelDes`,`createTime` from channel where channelName = #{channelname}")
    Map<String, Object> channelJudgingUniqueAdd(Map<String, Object> params);

    @Select("\t\tselect `id`,`channelId`,`channelName`,`channelType`,`channelDes`,`createTime` from channel where id !=#{id} and channelName = #{channelname}")
    Map<String, Object> channelJudgingUniqueEdit(Map<String, Object> params);

    @Select("    select `id`,`channelId`,`sdkId`,`sdkName`,`sdkVer`,`sdkDes`,`sdkType`,`createTime` from channel_sdk where sdkName = #{sdkname} and sdkVer= #{sdkver} ")
    Map<String, Object> sdkJudgingUniqueAdd(Map<String, Object> params);

    @Select("    select `id`,`channelId`,`sdkId`,`sdkName`,`sdkVer`,`sdkDes`,`sdkType`,`createTime` from channel_sdk where  id !=#{id} and sdkName = #{sdkname} and sdkVer= #{sdkver} ")
    Map<String, Object> sdkJudgingUniqueEdit(Map<String, Object> params);

    @Select("  SELECT\n" +
            "        t.`id`,\n" +
            "        t.`channelId`,\n" +
            "        t.`sdkId`,\n" +
            "        ch.channelName,\n" +
            "        sd.sdkName,\n" +
            "        t.`thirdName`,\n" +
            "        t.`thirdSdkId`,\n" +
            "        t.`thirdSdkName`,\n" +
            "        t.`thirdSdkVer`,\n" +
            "        t.`isOperate`,\n" +
            "        t.`sdkType`,\n" +
            "        t.`sdkPackName`,\n" +
            "        t.`sdkMethodName`,\n" +
            "        t.`isControlQuantity`,\n" +
            "        t.`ControlQuantity`,\n" +
            "        t.`sdkUrl`,\n" +
            "        t.`sdkDes`,\n" +
            "        t.`creatTime`\n" +
            "        FROM\n" +
            "        third_sdk t LEFT JOIN channel_sdk sd on t.sdkId=sd.sdkId\n" +
            "        LEFT JOIN channel ch on ch.channelId=t.channelId where t.thirdName = #{thirdname}  and t.thirdSdkVer= #{thirdsdkver} ")
    Map<String, Object> thirdSdkJudgingUniqueAdd(Map<String, Object> params);

    @Select("  SELECT\n" +
            "        t.`id`,\n" +
            "        t.`channelId`,\n" +
            "        t.`sdkId`,\n" +
            "        ch.channelName,\n" +
            "        sd.sdkName,\n" +
            "        t.`thirdName`,\n" +
            "        t.`thirdSdkId`,\n" +
            "        t.`thirdSdkName`,\n" +
            "        t.`thirdSdkVer`,\n" +
            "        t.`isOperate`,\n" +
            "        t.`sdkType`,\n" +
            "        t.`sdkPackName`,\n" +
            "        t.`sdkMethodName`,\n" +
            "        t.`isControlQuantity`,\n" +
            "        t.`ControlQuantity`,\n" +
            "        t.`sdkUrl`,\n" +
            "        t.`sdkDes`,\n" +
            "        t.`creatTime`\n" +
            "        FROM\n" +
            "        third_sdk t LEFT JOIN channel_sdk sd on t.sdkId=sd.sdkId\n" +
            "        LEFT JOIN channel ch on ch.channelId=t.channelId where  t.id !=#{id} and t.thirdName = #{thirdname}  and t.thirdSdkVer= #{thirdsdkver} ")
    Map<String, Object> thirdSdkJudgingUniqueEdit(Map<String, Object> params);

    @Select("\t\tselect `id`,`appName`,`appMark`,`packName`,`createTime` from platform_whitelist_dic where appName = #{appname}\n")
    Map<String, Object> platformWhitelistDicJudgingUniqueAdd(Map<String, Object> params);

    @Select("\t\tselect `id`,`appName`,`appMark`,`packName`,`createTime` from platform_whitelist_dic where id !=#{id} and appName = #{appname}")
    Map<String, Object> platformWhitelistDicJudgingUniqueEdit(Map<String, Object> params);

    @Select("\t\tselect `id`,`advUnionName`,`advUnionType`,`advUnionUrl`,`advUnionDes`,`createTime` from platform_advunion where advUnionName = #{advunionname}\n\n")
    Map<String, Object> platformAdvunionJudgingUniqueAdd(Map<String, Object> params);

    @Select("\t\tselect `id`,`advUnionName`,`advUnionType`,`advUnionUrl`,`advUnionDes`,`createTime` from platform_advunion where id !=#{id} and advUnionName = #{advunionname}")
    Map<String, Object> platformAdvunionJudgingUniqueEdit(Map<String, Object> params);

    @Select("\t\tselect `id`,`advUnionId`,`unionAccount`,`unionPassWord`,`isLock`,`accountDes`,`createTime` from platform_advunion_account where unionAccount = #{unionaccount} and advUnionId = #{advunionid}")
    Map<String, Object> platformAdvunionAccountJudgingUniqueAdd(Map<String, Object> params);

    @Select("\t\tselect `id`,`advUnionId`,`unionAccount`,`unionPassWord`,`isLock`,`accountDes`,`createTime` from platform_advunion_account where id !=#{id} and unionAccount = #{unionaccount} and advUnionId = #{advunionid}")
    Map<String, Object> platformAdvunionAccountJudgingUniqueEdit(Map<String, Object> params);

    @Select("\tSELECT\n" +
            "\tt.`id`,\n" +
            "\tt.`relaId`,\n" +
            "\tt.`advPositionId`,\n" +
            "\tt.`advPostitionName`,\n" +
            "\tt.`advPositionType`,\n" +
            "\tt.`advShowNum`,\n" +
            "\tt.`isShowBtn`,\n" +
            "\tt.`advPositionDes`,\n" +
            "\tt.`createTime`\n" +
            "FROM\n" +
            "\tthird_sdk_advunion_advposition_relationship t\n" +
            "LEFT JOIN third_sdk_advunion_relationship tsa ON tsa.id = t.relaId\n" +
            "WHERE  t.advPostitionName = #{advpostitionname} and t.relaId = #{relaid} ")
    Map<String, Object> advunionAdvpositionJudgingUniqueAdd(Map<String, Object> params);

    @Select("\tSELECT\n" +
            "\tt.`id`,\n" +
            "\tt.`relaId`,\n" +
            "\tt.`advPositionId`,\n" +
            "\tt.`advPostitionName`,\n" +
            "\tt.`advPositionType`,\n" +
            "\tt.`advShowNum`,\n" +
            "\tt.`isShowBtn`,\n" +
            "\tt.`advPositionDes`,\n" +
            "\tt.`createTime`\n" +
            "FROM\n" +
            "\tthird_sdk_advunion_advposition_relationship t\n" +
            "LEFT JOIN third_sdk_advunion_relationship tsa ON tsa.id = t.relaId\n" +
            "WHERE t.id !=#{id} and t.advPostitionName = #{advpostitionname} and t.relaId = #{relaid} ")
    Map<String, Object> advunionAdvpositionJudgingUniqueEdit(Map<String, Object> params);

    @Select("\tselect `id`,\t(\n" +
            "\t\tSELECT\n" +
            "\t\t\tcha.channelName\n" +
            "\t\tFROM\n" +
            "\t\t\tchannel cha\n" +
            "\t\tWHERE\n" +
            "\t\t\tcha.channelId = t.channelId\n" +
            "\t) channelName,\n" +
            "\t(\n" +
            "\t\tSELECT\n" +
            "\t\t\tsd.sdkName\n" +
            "\t\tFROM\n" +
            "\t\t\tchannel_sdk sd\n" +
            "\t\tWHERE\n" +
            "\t\t\tsd.sdkId = t.sdkId\n" +
            "\t) sdkName,`channelId`,`sdkId`,`channelDau`,`channelProfit`,`channelArpu`,`publishState`,\n" +
            "\t\tDATE_FORMAT(createTime, '%Y-%m-%d' ) `createTime` from channel_profit t where t.channelId = #{channelid} and t.sdkId = #{sdkid}")
    Map<String, Object> channelProfitJudgingUniqueAdd(Map<String, Object> params);

    @Select("\tselect `id`,\t(\n" +
            "\t\tSELECT\n" +
            "\t\t\tcha.channelName\n" +
            "\t\tFROM\n" +
            "\t\t\tchannel cha\n" +
            "\t\tWHERE\n" +
            "\t\t\tcha.channelId = t.channelId\n" +
            "\t) channelName,\n" +
            "\t(\n" +
            "\t\tSELECT\n" +
            "\t\t\tsd.sdkName\n" +
            "\t\tFROM\n" +
            "\t\t\tchannel_sdk sd\n" +
            "\t\tWHERE\n" +
            "\t\t\tsd.sdkId = t.sdkId\n" +
            "\t) sdkName,`channelId`,`sdkId`,`channelDau`,`channelProfit`,`channelArpu`,`publishState`,\n" +
            "\t\tDATE_FORMAT(createTime, '%Y-%m-%d' ) `createTime` from channel_profit t where t.id !=#{id} and  t.channelId = #{channelid} and t.sdkId = #{sdkid}")
    Map<String, Object> channelProfitJudgingUniqueEdit(Map<String, Object> params);


    @Select("\t\tselect `id`,`productName`,`productDomain`,`productDes`,`createTime` from product where productName = #{productname}\n")
    Map<String, Object> productUniqueAdd(Map<String, Object> params);

    @Select("\t\tselect `id`,`productName`,`productDomain`,`productDes`,`createTime` from product where id !=#{id}  and productName = #{productname}\n")
    Map<String, Object> productUniqueEdit(Map<String, Object> params);

    @Select("\t\tselect `id`,`channelId`,`channelName`,`channelType`,`channelDes`,`channelState`,`createTime` from product_channel where channelName = #{channelname}\n")
    Map<String, Object> productChannelUniqueAdd(Map<String, Object> params);

    @Select("\t\tselect `id`,`channelId`,`channelName`,`channelType`,`channelDes`,`channelState`,`createTime` from product_channel where id !=#{id} and channelName = #{channelname}\n")
    Map<String, Object> productChannelUniqueEdit(Map<String, Object> params);

    @Select("\t\tselect `id`,`productId`,`tagName`,`tagState`,`tagOnlineState`,`tagSort`,`createTime` from product_tags where productId = #{productid} and tagSort = #{tagsort} \n")
    Map<String, Object> productTagsJudgingUniqueAdd(Map<String, Object> params);

    @Select("\t\tselect `id`,`productId`,`tagName`,`tagState`,`tagOnlineState`,`tagSort`,`createTime` from product_tags where id !=#{id} and productId = #{productid} and tagSort = #{tagsort} \n")
    Map<String, Object> productTagsJudgingUniqueEdit(Map<String, Object> params);

    @Select("\t\tselect `id`,`productId`,`tagName`,`tagState`,`tagOnlineState`,`tagSort`,`createTime` from product_tags where productId = #{productid} and tagName = #{tagname} \n")
    Map<String, Object> tagNameproductTagsJudgingUniqueAdd(Map<String, Object> params);

    @Select("\t\tselect `id`,`productId`,`tagName`,`tagState`,`tagOnlineState`,`tagSort`,`createTime` from product_tags where id !=#{id} and productId = #{productid} and tagName = #{tagname} \n")
    Map<String, Object> tagNameproductTagsJudgingUniqueEdit(Map<String, Object> params);

    @Select("\t   SELECT\n" +
            "        t.`id`,\n" +
            "        t.`advPositionId`,\n" +
            "        t.`productId`,\n" +
            "        t.advInterval,\n" +
            "        p.productName,\n" +
            "        pt.advPositionTypeName,\n" +
            "        pt.advPositionType,\n" +
            "        t.`advPositionName`,\n" +
            "        t.`advPositionWide`,\n" +
            "        t.`advPositionHeight`,\n" +
            "        t.`imgSizeDes`,\n" +
            "        t.`imgScaleDes`,\n" +
            "        t.`imgFormatDes`,\n" +
            "        t.`isSsp`,\n" +
            "        t.`isDelete`,\n" +
            "        t.`createTime`\n" +
            "        FROM\n" +
            "        product_advposition t LEFT JOIN product p on t.productId=p.id\n" +
            "        LEFT JOIN product_advposition_type pt ON pt.advPositionType=t.advPositionType\n" +
            "        where t.productId = #{productid} and t.advPositionName=#{advpositionname}\n")
    Map<String, Object> productAdvpositionUniqueAdd(Map<String, Object> params);

    @Select("\t   SELECT\n" +
            "        t.`id`,\n" +
            "        t.`advPositionId`,\n" +
            "        t.`productId`,\n" +
            "        t.advInterval,\n" +
            "        p.productName,\n" +
            "        pt.advPositionTypeName,\n" +
            "        pt.advPositionType,\n" +
            "        t.`advPositionName`,\n" +
            "        t.`advPositionWide`,\n" +
            "        t.`advPositionHeight`,\n" +
            "        t.`imgSizeDes`,\n" +
            "        t.`imgScaleDes`,\n" +
            "        t.`imgFormatDes`,\n" +
            "        t.`isSsp`,\n" +
            "        t.`isDelete`,\n" +
            "        t.`createTime`\n" +
            "        FROM\n" +
            "        product_advposition t LEFT JOIN product p on t.productId=p.id\n" +
            "        LEFT JOIN product_advposition_type pt ON pt.advPositionType=t.advPositionType\n" +
            "        where t.id !=#{id} and t.productId = #{productid} and t.advPositionName=#{advpositionname}\n")
    Map<String, Object> productAdvpositionUniqueEdit(Map<String, Object> params);

    @Select("\t\tSELECT\n" +
            "\tt.`id`,\n" +
            "\tt.`productId`,\n" +
            " p.productName,\n" +
            "\tt.`advPositionId`,\n" +
            "pad.advPositionName,\n" +
            "\tt.`channelId`,\n" +
            "pc.channelName,\n" +
            "\tt.`advName`,\n" +
            "\tt.`advertiserName`,\n" +
            "\tt.`advEvent`,\n" +
            "\tt.`advDes`,\n" +
            "\tt.`advType`,\n" +
            "\tt.`advPrice`,\n" +
            "\tt.`advSort`,\n" +
            "\tt.`advImgUrl`,\n" +
            "\tt.`advUrl`,\n" +
            "\tt.`advJs`,\n" +
            "\tt.`advSettlement`,\n" +
            "\tt.`isDelete`,\n" +
            "\tt.`publishState`,\n" +
            "\tt.`isDirectional`,\n" +
            "\tt.`createTime`\n" +
            "FROM\n" +
            "\tproduct_advertisement t LEFT JOIN product p ON p.id=t.productId LEFT JOIN product_advposition pad ON pad.advPositionId=t.advPositionId\n" +
            "LEFT JOIN product_channel pc on t.channelId=pc.channelId\n" +
            " where t.advPositionId = #{advpositionid} and t.channelId = #{channelid} and t.advSort=#{advsort}")
    Map<String, Object> productAdvertisementUniqueAdd(Map<String, Object> params);

    @Select("\t\tSELECT\n" +
            "\tt.`id`,\n" +
            "\tt.`productId`,\n" +
            " p.productName,\n" +
            "\tt.`advPositionId`,\n" +
            "pad.advPositionName,\n" +
            "\tt.`channelId`,\n" +
            "pc.channelName,\n" +
            "\tt.`advName`,\n" +
            "\tt.`advertiserName`,\n" +
            "\tt.`advEvent`,\n" +
            "\tt.`advDes`,\n" +
            "\tt.`advType`,\n" +
            "\tt.`advPrice`,\n" +
            "\tt.`advSort`,\n" +
            "\tt.`advImgUrl`,\n" +
            "\tt.`advUrl`,\n" +
            "\tt.`advJs`,\n" +
            "\tt.`advSettlement`,\n" +
            "\tt.`isDelete`,\n" +
            "\tt.`publishState`,\n" +
            "\tt.`isDirectional`,\n" +
            "\tt.`createTime`\n" +
            "FROM\n" +
            "\tproduct_advertisement t LEFT JOIN product p ON p.id=t.productId LEFT JOIN product_advposition pad ON pad.advPositionId=t.advPositionId\n" +
            "LEFT JOIN product_channel pc on t.channelId=pc.channelId\n" +
            " where t.id !=#{id} and t.advPositionId = #{advpositionid} and t.channelId = #{channelid} and t.advSort=#{advsort}")
    Map<String, Object> productAdvertisementUniqueEdit(Map<String, Object> params);


    @Select("SELECT\n" +
            "        t.`id`,\n" +
            "        t.`channelId`,\n" +
            "        t.linkName,\n" +
            "        t.settlementMethod,\n" +
            "        t.settlementPrice,\n" +
            "        t.channelSettlementRate,\n" +
            "        t.platformSettlementRate,\n" +
            "        t.description,\n" +
            "        t.state,\n" +
            "        p.productName,\n" +
            "        pc.channelName,\n" +
            "        t.`productId`,\n" +
            "        t.`isChannelTemplate`\n" +
            "        FROM\n" +
            "        product_channel_relationship t\n" +
            "        LEFT JOIN product p ON t.productId = p.id\n" +
            "        LEFT JOIN product_channel pc ON pc.channelId = t.channelId where t.linkName = #{linkname}")
    Map<String, Object> productChannelRelationshipUniqueAdd(Map<String, Object> params);

    @Select("SELECT\n" +
            "        t.`id`,\n" +
            "        t.`channelId`,\n" +
            "        t.linkName,\n" +
            "        t.settlementMethod,\n" +
            "        t.settlementPrice,\n" +
            "        t.channelSettlementRate,\n" +
            "        t.platformSettlementRate,\n" +
            "        t.description,\n" +
            "        t.state,\n" +
            "        p.productName,\n" +
            "        pc.channelName,\n" +
            "        t.`productId`,\n" +
            "        t.`isChannelTemplate`\n" +
            "        FROM\n" +
            "        product_channel_relationship t\n" +
            "        LEFT JOIN product p ON t.productId = p.id\n" +
            "        LEFT JOIN product_channel pc ON pc.channelId = t.channelId where t.id !=#{id} and  t.linkName = #{linkname}")
    Map<String, Object> productChannelRelationshipUniqueEdit(Map<String, Object> params);

    @Select("select `id`,`productId`,`catalogName`,`catalogType`,`catalogUrl`,`catalogSort`,`catalogState`,`catalogOnlineState`,`catalogTemplate`,`catalogDes`,`createTime` from product_catalog where catalogName = #{catalogname} and productId=#{productid}")
    Map<String, Object> productCatalogUniqueAdd(Map<String, Object> params);

    @Select("select `id`,`productId`,`catalogName`,`catalogType`,`catalogUrl`,`catalogSort`,`catalogState`,`catalogOnlineState`,`catalogTemplate`,`catalogDes`,`createTime` from product_catalog where catalogSort = #{catalogsort}  and productId=#{productid}")
    Map<String, Object> productCatalogUniqueAddAdd(Map<String, Object> params);

    @Select("select `id`,`productId`,`catalogName`,`catalogType`,`catalogUrl`,`catalogSort`,`catalogState`,`catalogOnlineState`,`catalogTemplate`,`catalogDes`,`createTime` from product_catalog where id !=#{id} and catalogName = #{catalogname} and productId=#{productid}\n")
    Map<String, Object> productCatalogUniqueEdit(Map<String, Object> params);

    @Select("select `id`,`productId`,`catalogName`,`catalogType`,`catalogUrl`,`catalogSort`,`catalogState`,`catalogOnlineState`,`catalogTemplate`,`catalogDes`,`createTime` from product_catalog where id !=#{id} and catalogSort = #{catalogsort} and productId=#{productid}\n")
    Map<String, Object> productCatalogUniqueEditEdit(Map<String, Object> params);

}
